package persistence

import (
	"gitee.com/Gogo-gitee/gogo-cache/log"
	"os"
)

var (
	PersistenceFile *os.File
)

func init() {
	file, err := os.OpenFile("./persistence.txt", os.O_CREATE|os.O_RDWR|os.O_APPEND, 0666)
	if err != nil {
		log.Fatal(err)
	}
	PersistenceFile = file

}

func Record(key string, value []byte) {
	log.Debug("saving k/v")
	_, err := PersistenceFile.WriteString(key + "\n")
	if err != nil {
		log.Error(err)
	}
	value = append(value, []byte("\n")...)
	_, err = PersistenceFile.Write(value)
	if err != nil {
		log.Error(err)
	}
}

func Read() {

}
